package com.example.bingobox.model;

import java.util.Map;
import java.util.List;

public class Label {
    private String standard;  // "week" 或 "timespan"
    private CoupleData coupleData;

    public static class CoupleData {
        private Map<String, String> couple;

        public Map<String, String> getCouple() {
            return couple;
        }

        public void setCouple(Map<String, String> couple) {
            this.couple = couple;
        }
    }

    public static class LabelData {
        private Map<String, String> couple;  // 用于星期标签
        private List<TimeSpan> timeSpans;    // 用于时间段标签

        public Map<String, String> getCouple() { return couple; }
        public void setCouple(Map<String, String> couple) { this.couple = couple; }
        public List<TimeSpan> getTimeSpans() { return timeSpans; }
        public void setTimeSpans(List<TimeSpan> timeSpans) { this.timeSpans = timeSpans; }
    }

    public static class TimeSpan implements Comparable<TimeSpan> {
        private int startHour;
        private int startMinute;
        private int endHour;
        private int endMinute;
        private String label;

        // 获取规范化的时间（将0-5点视为前一天的24-29点）
        private int getNormalizedMinutes(int hour, int minute) {
            if (hour < 5) {
                hour += 24;
            }
            return hour * 60 + minute;
        }

        @Override
        public int compareTo(TimeSpan other) {
            int thisStart = getNormalizedMinutes(startHour, startMinute);
            int otherStart = getNormalizedMinutes(other.startHour, other.startMinute);
            
            if (thisStart != otherStart) {
                return thisStart - otherStart;
            }
            
            int thisEnd = getNormalizedMinutes(endHour, endMinute);
            int otherEnd = getNormalizedMinutes(other.endHour, other.endMinute);
            return thisEnd - otherEnd;
        }

        public boolean isValid() {
            int start = getNormalizedMinutes(startHour, startMinute);
            int end = getNormalizedMinutes(endHour, endMinute);
            return start < end;
        }

        // Getters and setters
        public int getStartHour() { return startHour; }
        public void setStartHour(int startHour) { this.startHour = startHour; }
        public int getStartMinute() { return startMinute; }
        public void setStartMinute(int startMinute) { this.startMinute = startMinute; }
        public int getEndHour() { return endHour; }
        public void setEndHour(int endHour) { this.endHour = endHour; }
        public int getEndMinute() { return endMinute; }
        public void setEndMinute(int endMinute) { this.endMinute = endMinute; }
        public String getLabel() { return label; }
        public void setLabel(String label) { this.label = label; }
    }

    public String getStandard() { return standard; }
    public void setStandard(String standard) { this.standard = standard; }

    public CoupleData getCoupleData() { return coupleData; }
    public void setCoupleData(CoupleData coupleData) { this.coupleData = coupleData; }
} 